<HTML>
    <HEAD>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>资源信息测试页面</title>
  <script type="text/javascript" src="./js/service.js"></script>
  <script type="text/javascript" src="/usr/share/javascript/jquery/jquery.min.js"></script>
  <script src="./js/qwebchannel.js"></script>
      <TITLE>资源信息测试页面</TITLE>
      <SCRIPT language=JavaScript>
              var websocket_url = 'ws://localhost:12345';
              var websocket = null;

              if (websocket === null) {
                  websocket = new WebSocket(websocket_url);
                  websocket.onopen = function () {
                      console.log("connect websocketserver success");
                  }
              } else {
                  websocket.close();
                  websocket = null;
              }

              function getMemTotalKiB() {
                  console.log("getMemTotalKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemTotalKiB();
                          }
                      );
              }

              function getMemUsagePercent() {
                  console.log("getMemUsagePercent")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemUsagePercent();
                          }
                      );
              }

              function getMemUsageKiB() {
                  console.log("getMemUsageKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemUsageKiB();
                          }
                      );
              }

              function getMemAvailableKiB() {
                  console.log("getMemAvailableKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemAvailableKiB();
                          }
                      );
              }

              function getMemFreeKiB() {
                  console.log("getMemFreeKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemFreeKiB();
                          }
                      );
              }


              function getMemVirtAllocKiB() {
                  console.log("getMemVirtAllocKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemVirtAllocKiB();
                          }
                      );
              }

              function getMemSwapTotalKiB() {
                  console.log("getMemSwapTotalKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemSwapTotalKiB();
                          }
                      );
              }

              function getMemSwapUsagePercent() {
                  console.log("getMemSwapUsagePercent")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemSwapUsagePercent();
                          }
                      );
              }

              function getMemSwapUsageKiB() {
                  console.log("getMemSwapUsageKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemSwapUsageKiB();
                          }
                      );
              }

              function getMemSwapFreeKiB() {
                  console.log("getMemSwapFreeKiB")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getMemSwapFreeKiB();
                          }
                      );
              }

              function getCpuCurrentUsage() {
                  console.log("getCpuCurrentUsage")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getCpuCurrentUsage();
                          }
                      );
              }

              function getUpTime() {
                  console.log("getUpTime")
                  new QWebChannel(websocket,function(channel){
                          var resource = channel.objects.resource;
                          resource.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          resource.getUpTime();
                          }
                      );
              }
              
        //-->
      </SCRIPT>
      <META content="MSHTML 6.00.2900.6287" name=GENERATOR>
      <style>
        table tr td{padding: 5px;}
      </style>
  
    </HEAD>
    <BODY>
      <div style="margin:30 5 20 5">
        <div>
          <input onclick="getMemTotalKiB()" type="button" value="物理内存总大小"  style="width: 100px; height: 50px">
          <input onclick="getMemUsagePercent()" type="button" value="物理内存使用率"  style="width: 100px; height: 50px">
          <input onclick="getMemUsageKiB()" type="button" value="物理内存使用大小"  style="width: 100px; height: 50px">
          <input onclick="getMemAvailableKiB()" type="button" value="可用物理内存大小"  style="width: 100px; height: 50px">
          <input onclick="getMemFreeKiB()" type="button" value="空闲物理内存大小"  style="width: 100px; height: 50px">
          <input onclick="getMemVirtAllocKiB()" type="button" value="虚拟内存总量"  style="width: 100px; height: 50px">
          <input onclick="getMemSwapTotalKiB()" type="button" value="Swap分区总大小"  style="width: 100px; height: 50px">
          <input onclick="getMemSwapUsagePercent()" type="button" value="Swap分区使用率"  style="width: 100px; height: 50px">
          <input onclick="getMemSwapUsageKiB()" type="button" value="Swap分区使用量"  style="width: 100px; height: 50px">
          <input onclick="getMemSwapFreeKiB()" type="button" value="Swap分区空闲大小"  style="width: 100px; height: 50px">
          <input onclick="getCpuCurrentUsage()" type="button" value="CPU瞬时使用率"  style="width: 100px; height: 50px">
          <input onclick="getUpTime()" type="button" value="开机天数"  style="width: 100px; height: 50px">
        
        </div>
        <div style="margin-top:20">
          <div align=left style="margin:5 0 5 0">回复：</div>
          <div>
          <textarea id="res" style="width:1000px;height:500px" ></textarea>
          </div>
        </div>
      </div>
    </BODY>
  </HTML>